package base.IO流;

import java.io.*;
import java.nio.charset.Charset;

public class 转换流 {
    public static void main(String[] args) throws IOException {
        File file = new File(".\\src\\base\\IO流\\gbk.txt");
        /*字节流转换流，使用字符的编码解码方法*/
        //1.JDK11前的方法
        InputStreamReader isr = new InputStreamReader(new FileInputStream(file),"GBK");
        int len;
        while ((len = isr.read()) != -1){
            //System.out.print((char) len);
        }

        //2.新
        FileReader fr = new FileReader(file, Charset.forName("GBK"));
        while ((len = fr.read()) != -1){
            System.out.print((char) len);
        }
    }
}
